import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DetailsVO, DetailsForm, DetailsQuery } from '@/api/ymxbh/details/types';

/**
 * 查询材料明细列表
 * @param query
 * @returns {*}
 */

export const listDetails = (query?: DetailsQuery): AxiosPromise<DetailsVO[]> => {
  return request({
    url: '/ymxbh/details/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询材料明细详细
 * @param id
 */
export const getDetails = (id: string | number): AxiosPromise<DetailsVO> => {
  return request({
    url: '/ymxbh/details/' + id,
    method: 'get'
  });
};

/**
 * 新增材料明细
 * @param data
 */
export const addDetails = (data: DetailsForm) => {
  return request({
    url: '/ymxbh/details',
    method: 'post',
    data: data
  });
};

/**
 * 修改材料明细
 * @param data
 */
export const updateDetails = (data: DetailsForm) => {
  return request({
    url: '/ymxbh/details',
    method: 'put',
    data: data
  });
};

/**
 * 删除材料明细
 * @param id
 */
export const delDetails = (id: string | number | Array<string | number>) => {
  return request({
    url: '/ymxbh/details/' + id,
    method: 'delete'
  });
};
